package com.hzlx.demo;

import java.util.concurrent.CompletableFuture;
public class P01 {
    public static void main(String[] args) {
        CompletableFuture<String> cf1 = CompletableFuture.supplyAsync(()->{
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            return "hello";
        })
        .thenApply(r->r + " OK！");
        try {
            String result = cf1.get();  // 阻塞
            System.out.println(result);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
